From 2d855ce5cf38c24cdaf12e4987cd9bab4bfe4360 Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Thu, 31 Mar 2011 23:23:29 +0200 Subject: [PATCH] NetworkMenu: fix some bugs for status items When more than one device exists, we need to reset the section title's device to null, and in that case we must show nothing (neither the switch nor the label, but an empty label is OK anyway). Also, we need to update the device statusItem immediately when constructing it, as we may not get any state-changed. https://bugzilla.gnome.org/show_bug.cgi?id=646074 --- js/ui/status/network.js | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/js/ui/status/network.js b/js/ui/status/network.js index 350ffdfbd..ed8e712ee 100644 --- a/js/ui/status/network.js +++ b/js/ui/status/network.js @@ -200,7 +200,7 @@ NMDeviceTitleMenuItem.prototype = { }, setStatus: function(text) { - if (text) { + if (text != null) { this._statusLabel.text = text; this._statusBin.child = this._statusLabel; this.actor.reactive = false; @@ -367,6 +367,8 @@ NMDevice.prototype = { this.deactivate(); this.emit('enabled-changed'); })); + + this._updateStatusItem(); } this.section = new PopupMenu.PopupMenuSection(); @@ -383,10 +385,19 @@ NMDevice.prototype = { GObject.Object.prototype.disconnect.call(this.device, this._stateChangedId); this._stateChangedId = 0; } + if (this._carrierChangedId) { + // see above for why this is needed + GObject.Object.prototype.disconnect.call(this.device, this._carrierChangedId); + this._carrierChangedId = 0; + } + if (this._firmwareChangedId) { + GObject.Object.prototype.disconnect.call(this.device, this._firmwareChangedId); + this._firmwareChangedId = 0; + } this._clearSection(); - if (this.titleItem) - this.titleItem.destroy(); + if (this.statusItem) + this.statusItem.destroy(); this.section.destroy(); }, @@ -633,6 +644,14 @@ NMDevice.prototype = { break; } + this._updateStatusItem(); + + this._clearSection(); + this._createSection(); + this.emit('state-changed'); + }, + + _updateStatusItem: function() { if (this._carrierChangedId) { // see above for why this is needed GObject.Object.prototype.disconnect.call(this.device, this._carrierChangedId); @@ -645,10 +664,6 @@ NMDevice.prototype = { this.statusItem.setStatus(this.getStatusLabel()); this.statusItem.setToggleState(this.connected); - - this._clearSection(); - this._createSection(); - this.emit('state-changed'); }, _substateChanged: function() { @@ -1666,6 +1681,8 @@ NMApplet.prototype = { managedDevices.forEach(function(dev) { dev.statusItem.actor.show(); }); + // remove status text from the section title item + item.updateForDevice(null); } } }, -- 2.39.5